﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ChuanYe.CountyFireManagement.Api.Models;
using ChuanYe.CountyFireManagement.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace ChuanYe.CountyFireManagement.Api.Controllers
{
    /// <summary>
    /// 登录
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        /// <summary>
        /// 登录接口
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultDto<dynamic,dynamic,dynamic,dynamic> Post(LoginRequest obj)
        {
            ResultDto<dynamic,dynamic, dynamic, dynamic> result = new ResultDto<dynamic,dynamic, dynamic, dynamic>();
            try
            {
                result= BLL.UserBLL.Instance.Login(obj.AccountName, obj.Password);
                result.FourthParam = HttpContext.GetClientIp();
            }
            catch (Exception ex)
            {
                result.Status = 500;
                result.Message = "/Login/Server Error";
                LogHelper.Error(result.Message,ex);
            }
            return result;
        }
    }
}